package com.sf.asp.entity.vo;

import com.sf.asp.constants.enumeration.ResponseStatusEnum;

/**
 * 返回结果信息封装
 */
public class ResponseInfo {

    /**
     * 信息
     */
    private String msg;

    /**
     * 编码
     */
    private Integer code;

    /**
     * 数据
     */
    private Object data;


    public ResponseInfo(){
        this.code = ResponseStatusEnum.SUCCESS.getCode();
    }


    public ResponseInfo(Object data){
        this.code = ResponseStatusEnum.SUCCESS.getCode();
        this.data = data;
    }


    public ResponseInfo(Integer code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    /**
     * 成功
     * @return
     */
    public static ResponseInfo ok(){
        return new ResponseInfo();
    }

    /**
     * 成功
     * @return
     */
    public static ResponseInfo ok(Object data){
        return new ResponseInfo(data);
    }


    /**
     * 失败
     * @return
     */
    public static ResponseInfo error(Integer code,String msg){
        return new ResponseInfo(code,msg);
    }
}
